/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package action;

import dao.ProductDAO;
import dto.Product;
import java.sql.SQLException;
import java.util.Collection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * @author duonghung1369
 */

public class ProductController extends BaseController{
    private Product product;
    private Collection<Product> products;
    private ProductDAO productDAO;
    private int category_id;
    private int id;

    private Log log = LogFactory.getLog(ProductController.class);

    public ProductController() {
        super();
        productDAO = new ProductDAO(_database);
        products = productDAO.getLastestProducts();
        log.info("ProductController init constructor finished!");
    }

    public String list(){
        products = productDAO.getProductsOfCategory(category_id);

        return SUCCESS;
    }

    public String detail() throws SQLException{
        product = productDAO.get(id);
        return SUCCESS;
    }

    public String product_detail(){
        return SUCCESS;
    }

    /**
     * @return the product
     */
    public Product getProduct() {
        return product;
    }

    /**
     * @param product the product to set
     */
    public void setProduct(Product product) {
        this.product = product;
    }

    /**
     * @return the products
     */
    public Collection<Product> getProducts() {
        return products;
    }

    /**
     * @param products the products to set
     */
    public void setProducts(Collection<Product> products) {
        this.products = products;
    }

    /**
     * @return the category_id
     */
    public int getCategory_id() {
        return category_id;
    }

    /**
     * @param category_id the category_id to set
     */
    public void setCategory_id(int category_id) {
        this.category_id = category_id;
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    
}